<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div>RegExp</div>
  <script>
    
    let str = `null
    sdwd awgABvduhbwikPS
    wdwd-sdw

    null
    about
    456789
    about-sa wahbdABuyawgduwabhd dwaawdhiawdhiawuPSbwadvutfvtyddrf
    fdahduyawgdtawywaehu  wiuegwqeihqwuoh wqehwi`
    
    let result = str.replace(/[\d\D]*(\w{2})[\d\D]*\1[\d\D]*/g, '$1')
    console.log(result)
    
    //  \n?(?<!:)\s*//.*
    
    function deleteComment(str) {
      return str.replace(/\n?(?<!:)\s*\/\/.*/gm, '');
    }
    
    
    // 5.1 字符串trim方法模拟
    function trim(str) {
      return str.replace(/^\s+|\s$/g, '');
    } 
    
    
    console.log(trim('  hello world  '));
    
    // 5.2 将每个单词的首字母转换为大写
    function titleiz(str) {
      return str.toUpperCase().replace(/(?:^|\s)\w/g, function(c) {
        return c.toUpperCase();
      })
    }
    
    // 5.3 驼峰化
    function camelize(str) {
      return str.replace(/[-_\s]+(.)?/g, function(match, c) {
        return c ? c.toUpperCase() : '';
      });
    }
    
    // 5.4 中划线化
    function dasherize(str) {
      return str.replace(/(A-Z)/g, '-$1').replace(/[-_\s]+/g,'-').toLowerCase();
    }
    
    console.log( dasherize('MozTransform') )
    
    
    
    
    
  </script>
</body>
</html>